﻿using PcProject.Domain.Models.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PcProject.Domain.IRepository
{
    /// <summary>
    /// 定义一个泛型仓储接口，单词Repository 中文意思：仓储
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IRepository<T> where T : class
    {
        /// <summary>
        /// 查询所有数据
        /// </summary>
        /// <returns></returns>
        Task<List<T>> ShowAsync();

        //查询
        /// <summary>
        /// 根据主键查询(返回单条数据)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> GetByIdAsync(int id);

        /// <summary>
        /// 根据条件查(返回集合数据)
        /// </summary>
        /// <param name="whereCondition"></param>
        /// <param name="paras"></param>
        /// <returns></returns>
        Task<IEnumerable<T>> GetListAsync(string whereCondition = "", object paras = null);

        /// <summary>
        /// 分页查询(返回集合数据和总条数)
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCount"></param>
        /// <param name="whereCondition"></param>
        /// <param name="paras"></param>
        /// <returns></returns>
        Task<AsyncProgram<T>> GetPageListAsync(int pageIndex, int pageSize, string whereCondition = "", object paras = null);

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        Task<int> InsertAsync(T obj);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<int> DeleteAsync(int id);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        Task<int> UpdateAsync(T obj);

    }
}
